package com.allenkerr.web;

import com.allenkerr.model.Person;
import com.allenkerr.service.IPersonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author 小柯
 * @date 2017/12/20
 */
@RestController
@RequestMapping("/person")
public class PersonController {

  @Autowired
  private IPersonService personService;

  private static final Logger logger = LoggerFactory.getLogger(PersonController.class);

  @GetMapping("/{uuid}")
  public ResponseEntity<Person> getPerson(@PathVariable String uuid) {

    logger.info("PersonController.getPerson");

    return ResponseEntity.ok(personService.findPersonByUuid(uuid));
  }

  @PatchMapping("/{uuid}")
  public ResponseEntity<Person> updatePerson(@PathVariable String uuid) {

    logger.info("PersonController.updatePerson");

    return ResponseEntity.ok(personService.updatePersonByUuid(uuid));
  }

}
